|
|
|
|
|
|
|
You set the initial value by using the ListIndex property. For example, if "U.S. Citizen" is the fourth entry in the list, you can use the following code to cause that item to be pre-selected (recall that ListIndex begins its counting with zero): |
|
|
|
|
|
|
|
|
This statement causes the fourth item in the list to be displayed when the combo box is first shown. (Remember, the list indexes start at 0.) You can set the initial choice with any of the three combo box styles. You also can set the initial choice of the combo box by setting the Text property to the value you want. If you do not set an initial choice by setting the index, the text contained in the Text property is displayed. |
|
|
|
|
CAUTION
|
|
|
|
|
The initial value of the Text property is the name of the combo box. If you do not want this name to appear in your combo box on startup, set either the ListIndex property or the Text property in code. |
|
|
|
|
|
|
| |
|
|
|
|
If you want your combo box to be blank when the form is first shown, simply delete the contents of the Text property while you are in the design environment. |
|
|
|
|
|
|
|
|
|
|
Working with Choices Not on the List |
|
|
|
|
|
|
|
|
The drop-down list is useful for presenting several choices in a small amount of space. However, the real power of the combo box is its capability to allow users to enter choices other than those on the list. This capability is available with the other two styles of combo boxesthe simple combo box and the drop-down combo box. Both styles provide a list of items from which you can select, and both allow you to enter other values. The difference between the two styles is the way in which you access items already in the list. |
|
|
|
|
|
|
|
|
You set up a simple combo box by drawing the control on the form and then setting the Style property to 1 - Simple Combo. With the simple combo box, the users can access the items in the list using the mouse or the arrow keys. If the users don't find what they want on the list, they can type new choices. |
|
|
|
|
|
|
|
|
The drop-down combo box works like a combination of the drop-down list and the simple combo box. You select an item from the list the same way you would for a drop-down list, but you also can enter a value that is not on the list. You create the drop-down combo box by setting the Style property to 0 - Dropdown Combo. The drop-down combo box is the default setting of the Style property. |
|
|
|
|
|
|
|
|
As with the list box and the drop-down list, you can use the List property to add items to the list of selections. You also can modify the list for any of the combo box styles while your program is running. As with the list box control, you modify the list by using the AddItem, RemoveItem, and Clear methods. |
|
|
|
|
|